//
//  XWTableViewCell_c.m
//  网易新闻
//
//  Created by dllo on 15/9/21.
//  Copyright (c) 2015年 Lx. All rights reserved.
//

#import "ZGL24NewsCell_photos.h"
#import "ZGL24NewsModel.h"
#import <SDWebImage/UIImageView+WebCache.h>

@interface ZGL24NewsCell_photos()
@property(nonatomic, retain)UIImageView *img_a;
@property(nonatomic, retain)UIImageView *img_b;
@property(nonatomic, retain)UIImageView *img_c;
@property(nonatomic, retain)UILabel *title;//标题
@property(nonatomic, retain)UILabel *source;//作者
@property(nonatomic, retain)UIView *back;//背景
@end
@implementation ZGL24NewsCell_photos
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _back = [[UIView alloc]init];
        [self.contentView addSubview:_back];
        
        _title = [[UILabel alloc]init];
        _title.numberOfLines = 0;
        [_title sizeToFit];
        [_back addSubview:_title];
        
        _img_a = [[UIImageView alloc]init];
        _img_a.backgroundColor = [UIColor grayColor];
        [_back addSubview:_img_a];
        
        _img_b = [[UIImageView alloc]init];
        _img_b.backgroundColor = [UIColor grayColor];
        [_back addSubview:_img_b];
        
        _img_c = [[UIImageView alloc]init];
        _img_c.backgroundColor = [UIColor grayColor];
        [_back addSubview:_img_c];
        
        _source = [[UILabel alloc]init];
        _source.textColor = [UIColor lightGrayColor];
        _source.font = [UIFont systemFontOfSize:14];
        [_back addSubview:_source];
        
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.backgroundColor = backColor;
    _back.backgroundColor = foreColor;
    _title.textColor = artiColor;
    _back.frame = CGRectMake(0, 1, Width, (int)85*ScaleX+60);
    _img_a.frame = CGRectMake((int)9*ScaleX, 10, (int)113*ScaleX, (int)85*ScaleX);
    _img_b.frame = CGRectMake((int)131*ScaleX, 10, (int)113*ScaleX, (int)85*ScaleX);
    _img_c.frame = CGRectMake((int)253*ScaleX, 10, (int)113*ScaleX, (int)85*ScaleX);
    _title.frame = CGRectMake((int)10*ScaleX, (int)85*ScaleX+15, (int)355*ScaleX, 20);
    _source.frame = CGRectMake((int)10*ScaleX, (int)85*ScaleX+40, (int)355*ScaleX, 20);
}

- (void)setMod:(ZGL24NewsModel *)mod{
    _height = (int)85*ScaleX+70;
    
    _title.text= mod.title;
    [_img_a sd_setImageWithURL:mod.imgsrc placeholderImage:[UIImage imageNamed:@"squirrel"]];
    [_img_b sd_setImageWithURL:[mod.imgextra[0]objectForKey:@"imgsrc"] placeholderImage:[UIImage imageNamed:@"squirrel"]];
    [_img_c sd_setImageWithURL:[mod.imgextra[1]objectForKey:@"imgsrc"] placeholderImage:[UIImage imageNamed:@"squirrel"]];
    if (!mod.source) {
        mod.source = @"";
    }
    _source.text = [[NSString stringWithFormat:@"%@    %@", mod.source, mod.ptime]stringByReplacingOccurrencesOfString:@"$" withString:@""];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end

